function [blon,blat,balt,dbi,sbie]=cadsph3(blon,blat,balt,dbi,sbie,C,CON);
%*** ***************************************************************
%*** * Calculates longitude, latitude and altitude from earth position
%*** *
%*** * Argument Output:
%*** *          BLON =Missile longitude - rad
%*** *          BLAT =Missile latitude - rad
%*** *          BALT =Missile altitude above sea level - rad
%*** *          DBI =Missile distance from earth center - m
%*** * Argument Input:
%*** *          SBIE(3) =Missile position wrt earth center in earth coor - m
%*** *
%*** * MODIFICATION HISTORY
%*** * 960628 Created by Peter Zipfel
%*** * 000128 Resolved multivalued ARCSIN function, PZi
%*** *
%*** ***************************************************************

  %*** INPUT FROM EXEC
  rearth = C(CON.REARTH);
  crad = C(CON.CRAD);

  %*** LATITUDE

  dbi=sqrt(sbie(1).^2+sbie(2).^2+sbie(3).^2);
  dum1=sbie(3)./dbi;
  if(abs(dum1) > 1.)
    dum1=(abs(1.).*sign(dum1));
  end;
  blat=asin(dum1);

  %*** ALTITUDE

  balt=dbi-rearth;
  baltft=balt.*3.2808399;

  %*** LONGITUDE

  dum3=sbie(2)./sqrt(sbie(1).^2+sbie(2).^2);
  if(abs(dum3) > 1.)
    dum3=(abs(1.).*sign(dum3));
  end;
  dum4=asin(dum3);

  %*** RESOLVING THE MUTLIVALUED ARCSIN FUNCTION

  %1. quadrant
  if(sbie(1) >= 0.&&sbie(2) >= 0.)
    alamda=dum4;
  end;
  %2. quadrant
  if(sbie(1) < 0.&&sbie(2) >= 0.)
    alamda=180../crad-dum4;
  end;
  %3. quadrant
  if(sbie(1) < 0.&&sbie(2) < 0.)
    alamda=180../crad-dum4;
  end;
  %4. quadrant
  if(sbie(1) >= 0.&&sbie(2) < 0.)
    alamda=360../crad+dum4;
  end;
  blon=alamda;
  %east pos., west neg.
  if(blon >(180../crad))
    blon=-((360../crad)-blon);
  end;

  return;
end %subroutine cadsph3